/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.wii.elpro.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

/**
 *
 * @author hendro
 */
@Entity
public class Produk implements Serializable {
    
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    @Column(name="kode",length = 255)
    private String kode;
    @Column(name = "nama", length = 255)
    private String nama;
    @Column(name = "berat")
    private double weight;
    @ManyToOne
    @JoinColumn(name = "price_id")
    private Price hargaHpp; //di view beri field Unit dan Jenis
    @Column(name = "stok_li")
    private double stockLI;
    @Column(name = "stock_le")
    private double stockLE;    
    @OneToMany(mappedBy = "material")
    private List<ProdukMaterial> produkMaterials=new ArrayList<ProdukMaterial>();

    
    
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Produk)) {
            return false;
        }
        Produk other = (Produk) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.wii.elpro.entity.Produk[id=" + id + "]";
    }

    public String getKode() {
        return kode;
    }

    public void setKode(String kode) {
        this.kode = kode;
    }

    public String getNama() {
        return nama;
    }

    public void setNama(String nama) {
        this.nama = nama;
    }

    public double getWeight() {
        return weight;
    }

    public void setWeight(double weight) {
        this.weight = weight;
    }

    public Price getHargaHpp() {
        return hargaHpp;
    }

    public void setHargaHpp(Price hargaHpp) {
        this.hargaHpp = hargaHpp;
    }

    public List<ProdukMaterial> getProdukMaterials() {
        return produkMaterials;
    }

    public void setProdukMaterials(List<ProdukMaterial> produkMaterials) {
        this.produkMaterials = produkMaterials;
    }

    public double getStockLI() {
        return stockLI;
    }

    public void setStockLI(double stockLI) {
        this.stockLI = stockLI;
    }

    public double getStockLE() {
        return stockLE;
    }

    public void setStockLE(double stockLE) {
        this.stockLE = stockLE;
    }

}
